
def add_web_table(state, web_table):
    state['web_table'].append(web_table)


def update_web_table_by_key(state, key, new_data):
    # 根据 key 查找 web_table 中的项
    web_table = state.get('web_table', [])
    for item in web_table:
        if item.get('key') == key:
            item.update(new_data)
            return
    raise ValueError(f"Item with key '{key}' not found in 'web_table'")


# 查询全部web
def get_web_tables(store):
    state = store.state
    return state['web_table']


# 使用key查询单个web
def get_web_table_by_key(store, key):
    state = store.state
    # 根据 key 查找 web_table 中的项
    web_table = state.get('web_table', [])
    for item in web_table:
        if item.get('key') == key:
            return item
    raise ValueError(f"Item with key '{key}' not found in 'web_table'")



